package com.ojoin.ojoin.eb_spider.service.stat;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.ojoin.ojoin.eb_spider.utils.WebServiceUtils;
import com.ojoin.trade.common.utils.LogUtils;
import com.ojoin.trade.common.utils.TimeUtils;
import com.ojoin.trade.supplyloan_core.web.domain.TbCatchdataStrategy;
import com.ojoin.trade.supplyloan_core.web.domain.TbSlLoanStatTotal;
import com.ojoin.trade.supplyloan_core.web.domain.TbSlPlatformUser;
import com.ojoin.trade.supplyloan_core.web.domain.TbSlSupplyInventory;
import com.ojoin.trade.supplyloan_core.web.domain.TbSlSupplyPayment;
@Service
public class ThirdSellerJDstat  extends BaseStatTotal{

	private Logger log = LoggerFactory.getLogger(ThirdSellerJDstat.class);
	
	@Override
	public void invoke(TbSlPlatformUser user, TbCatchdataStrategy ca,TbSlLoanStatTotal total) throws Exception {

        String time = TimeUtils.getCurDate();
		
		long paymoney = WebServiceUtils.getSupplyPaymentMoneyByplateformId( user.getId(), ca,time, time, TbSlSupplyPayment.WAITPAY);
		long settorcheck = WebServiceUtils.getSupplyPaymentMoneyByplateformId( user.getId(),ca, time, time, TbSlSupplyPayment.CHECKEDPAY);

        long inveInMoney = WebServiceUtils.getSupplyInventoryMoneyByplateformId(user.getId(), ca,time, time, TbSlSupplyInventory.IN);
		
		long inveOutMoney = WebServiceUtils.getSupplyInventoryMoneyByplateformId(user.getId(),ca, time, time, TbSlSupplyInventory.OUT);

		total.setTotalUnsettleInstoreorder(Long.valueOf(inveInMoney));
		total.setTotalUnenterinRefundorder(Long.valueOf(inveOutMoney));
		total.setTotalUnpaySettleorder(Long.valueOf(paymoney));
		total.setTotalUnpaySettleorderCheck(Long.valueOf(settorcheck));

		LogUtils.info(
				log,
				" %s --> [all store in %s] + [all store out %s ] + [all Unpay %s] ",
				user.getUsername(), inveInMoney, inveOutMoney, paymoney);
		
		
		
		
	}

}
